<?php

use yii\db\Migration;

/**
 * Class m191009_064407_posts_collect
 */
class m191009_064407_posts_collect extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="帖子项目收藏表"';
        $this->createTable('{{%posts_collect}}', [
            'id' => $this->primaryKey(),
            'posts_id' => $this->integer()->defaultValue(0)->comment('帖子id'),
            'item_id' => $this->integer()->defaultValue(0)->comment('项目id'),
            'member_id' => $this->integer()->comment('用户id'),
            'is_collect' => $this->smallInteger()->comment('是否收藏 1是2否'),
            'is_like' => $this->smallInteger()->comment('是否点赞 1是2否'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%posts_collect}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m191009_064407_posts_collect cannot be reverted.\n";

        return false;
    }
    */
}
